<template>
  <div>
    <el-row>
      <el-col class="myradio" :span="19">
        <el-radio-group v-model="radio" >
          <el-radio label="1">全部</el-radio>
          <el-radio label="2">追评</el-radio>
          <el-radio label="3">好评</el-radio>
          <el-radio label="4">中评</el-radio>
          <el-radio label="5">差评</el-radio>
        </el-radio-group>
      </el-col>
    </el-row>
    <el-row v-for="a in evaluates">
      <el-col :span="2" :offset="1">
        <img :src="a.comment.user.usersTopImg" alt="" width="50px" height="50px">
        <br>
        {{a.comment.user.uname.substr(0,1)}}***
        {{a.comment.user.uname.substr(a.comment.user.uname.length-1,a.comment.user.uname.length)}}
      </el-col>
      <el-col style="border-bottom: 1px solid #E4E7ED; margin-bottom: 20px;"  :span="16" v-if="a.content.length==0">15天内买家未作出评价</el-col>
      <el-col style="border-bottom: 1px solid #E4E7ED; margin-bottom: 20px;" :span="16" v-if="a.content.length>0">
        {{a.content}} <br>
        <span class="mytime">{{a.comment.etime}}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12" :offset="4">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageno"
          :page-sizes="[5, 10, 15, 20]"
          :page-size="pagesize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </el-col>
    </el-row>
    <el-empty v-if="evaluates.length==0" description="暂无数据"></el-empty>
  </div>
</template>

<script>
  export default {
    name: "ShopEvaluates",
    data() {
      return {
        radio:"1",
        evaluates: [],
        evaluate: {
          gid: null,
        },
        pageno: 1,
        pagesize: 5,
        total: 1,
      }
    },
    methods: {
      getData() {
        let params = {};
        params["pageno"] = this.pageno;
        params["pagesize"] = this.pagesize;
        params["gid"] = this.evaluate.gid;
        this.$axios
          .get("evaluate/evaluate.action", {params: params})
          .then(res => {
            res.data.records.forEach(item=>{
              item.comment.user.usersTopImg=
                this.$store.state.path+ item.comment.user.usersTopImg;
            })
            this.evaluates = res.data.records;
            this.total = res.data.total;
          })
          .catch(err => {
            this.$message.error(err)
          })
      },
      handleSizeChange() {
        //每页范围
        this.pagesize = val;
        this.getData();
      },
      handleCurrentChange() {
        //当前页
        this.pageno = val;
        this.getData();
      }
    }
  }
</script>

<style scoped>
.myradio{
  height: 50px;
  line-height: 50px;
  border: 1px solid #E4E7ED;
  margin-bottom: 20px;
}
  .mytime{
    display: inline-block;
    color: rgba(153,169,161,0.8);
    padding-top: 20px;
  }
</style>
